package io.renren.modules.app.controller;

import java.util.Arrays;
import java.util.Map;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.renren.modules.app.req.GoodsListReq;
import io.renren.modules.app.vo.GoodsListVO;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.app.entity.GoodsEntity;
import io.renren.modules.app.service.GoodsService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 *
 *
 * @author MR.XU
 * @email 260139486@qq.com
 * @date 2021-01-18 15:59:47
 */
@RestController
@RequestMapping("api/goods")
@Api(value = "商品接口", tags = "APP商品控制器")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;

    /**
     * 商品列表
     */
    @GetMapping("/list")
    @ApiOperation(value = "查询", notes = "传入goods", response = GoodsListVO.class)
    public R list(Page<GoodsListVO> page, GoodsListReq goodsListReq){
        PageUtils pages = goodsService.getGoodsList(page,goodsListReq);
        return R.ok().put("page", pages);
    }
    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    @ApiOperation(value = "查询", notes = "传入id", response = GoodsEntity.class)
    public R info(@PathVariable("id") Integer id){
		GoodsEntity goods = goodsService.getById(id);

        return R.ok().put("goods", goods);
    }
}
